cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 14)

# 项目名称
project(BeamSecPropCalculator LANGUAGES CXX)

# 获取源文件
file(GLOB SOURCES 
    ${CMAKE_CURRENT_SOURCE_DIR}/FormulaMethod/Bar/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/FormulaMethod/Beam/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/NumericalMethod/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/NumericalMethod/SectionCalculator/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/NumericalMethod/SectionCalculator/SectionElement/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/SectionParser/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/NumericalMethod/ThirdLibrary/triangle.c
    )

# 添加动态库
add_library(${PROJECT_NAME} SHARED ${SOURCES})

# 目标添加链接库
target_link_libraries(${PROJECT_NAME} PRIVATE DBManager DataStructure Algebra FileSystem Integration Logging)

# 目标添加编译选项
target_compile_definitions(${PROJECT_NAME} PRIVATE 
    EXPORTING_BeamSecPropCalculator
    EXPORTING_Integration
    TRILIBRARY                       
    ANSI_DECLARATORS
    VOID=void)

# 安装头文件
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Common/                    DESTINATION include/SGFem/BeamSecPropCalculator/Common)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/FormulaMethod/Interface/   DESTINATION include/SGFem/BeamSecPropCalculator/FormulaMethod/Interface)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/NumericalMethod/Interface/ DESTINATION include/SGFem/BeamSecPropCalculator/NumericalMethod/Interface)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/SectionParser/             DESTINATION include/SGFem/BeamSecPropCalculator/SectionParser
    FILES_MATCHING PATTERN "*.h" PATTERN "UnitTest" EXCLUDE)

# 单独安装BarSectionFormulaCalculator
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/FormulaMethod/Beam/RodBeamSectionFormulaCalculator.h DESTINATION include/SGFem/BeamSecPropCalculator/FormulaMethod/Beam)

# 安装目标
install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin)

# 添加单元测试子项目
if(SG_BUILD_UNIT_TEST)
    add_subdirectory(UnitTest)
endif()